<%@ page import="gongju.DBUtil" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.SQLException" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2023-05-27
  Time: 14:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>$Title$</title>
  </head>
  <body>
  <style>
    table{
      border-collapse: collapse;
      text-align: center;
    }
  </style>
  <table border="1" width="400">
    <tr><th>编号</th><th>姓名</th><th>性别</th><th>选择</th></tr>
    <%
      String sql = "select * from student";
      ResultSet re = DBUtil.query(sql);
      while (re.next()){
      int id = re.getInt("id");
      String name = re.getString("name");
      String sex = re.getString("sex");
    %>
    <tr>
      <td><%=id%></td>
      <td><%=name%></td>
      <td><%=sex%></td>
      <td>
        <a href="/update?id=<%=id%>">修改</a>
        <a href="/delete?id=<%=id%>">删除</a>
      </td>
    </tr>
    <%
    }
    %>
  </table>
  <form action="/add" method="get">
    <input type="submit" value="添加数据">
  </form>
  </body>
</html>